package game;
import java.awt.Point;
import java.util.*;

import org.w3c.dom.Element;

/**
 * <p>Creates the {@code King} for each player in the game of chess.</p>
 * 
 * @author Nicole Waldrum
 * @date January 30, 2010
 * @version 1.0
 * 
 * @author Mark Kelly
 * @date February 19, 2010
 * @version 2.0
 * 
 * @author Trevor Bastian
 * @date February 20, 2010
 * @version 2.0
 */
public class King extends Piece {
	// add this Piece subclass to the list of Piece types
	static {
		Piece.addPieceType(King.class);
	}
	
	private static final String DEFAULT_LETTER = "K";

	/**
	 * <p>Creates a new instance of {@code King}</p>
	 * 
	 * @param name the name of this {@code King}
	 * @param position the initial position of this {@code King}
	 * @param team the {@code Team} that this {@code King} is on
	 */
	public King(String name, Point position, Team team) {
		super(name, position, team);
	}

	/**
	 * <p>Creates a new instance of {@code King}</p>
	 * 
	 * @param position the initial position of this {@code King}
	 * @param team the {@code Team} that this {@code King} is on
	 */
	public King(Point position, Team team) {
		super(position, team);
	}

	/**
	 * Creates a King from XML
	 * @param king
	 */
	public King (Element king) {
		super (king);
	}
	
	/**
	 * {@inheritDoc}
	 */
	public String toLetter() {
		return DEFAULT_LETTER;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public List<Point> checkMovePattern(Point dest) {
		List<Point> ret = new ArrayList<Point>();
		return ret;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean isValidMove(Piece piece, Point dest) {
		Point start = piece.getLocation();
		if ( Math . abs ( start . getX () - dest . getX () ) <= 1 && ( Math . abs ( start . getY () - dest . getY () ) <= 1 )) {
			return super.isValidMove(piece, dest);
		}
		return false;
	}
}
